<template>
  <div>
    <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">
      <li class="mui-table-view-cell">
        <div class="mui-table">
          <div class="mui-table-cell mui-col-xs-10">
            <h4 class="mui-ellipsis">{{ datalist.goods_name }}</h4>
            <h5>价格： {{ datalist.goods_price }}</h5>
            <p class="mui-h6 mui-ellipsis">
              商品重量: {{ datalist.goods_weight }}
            </p>
          </div>
          <div class="mui-table-cell mui-col-xs-2 mui-text-right">
            <span class="mui-h5">
              创建时间: {{ datalist.add_time | dataFormat }}</span
            >
          </div>
        </div>
      </li>
    </ul>
    <!-- 商品评论 -->
    <comment></comment>
  </div>
</template>

<script>
import comment from '../comment_list.vue'
import Vue from 'vue'
import { Toast } from 'vant'
Vue.use(Toast)
export default {
  data() {
    return {
      // 这是通过vux获取到的id
      dataid: this.$store.state.id,
      datalist: {}
    }
  },
  created() {
    this.getinfo()
  },
  methods: {
    async getinfo() {
      const { data: res } = await this.$http.get(`goods/${this.dataid}`)
      // console.log(res)
      if (res.meta.status !== 200) {
        return Toast('查询id失败')
      }
      this.datalist = res.data
    }
  },
  components: {
    comment
  }
}
</script>

<style lang="less" scoped></style>
